package com.saturn.titan.core.bean;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springside.modules.utils.Collections3;

import com.google.common.collect.Lists;
import com.saturn.titan.core.bean.base.DatabaseBean;
import com.saturn.titan.core.repository.mybatis.annotations.DbField;
import com.saturn.titan.core.repository.mybatis.annotations.DbTable;
@DbTable(table = "user")
public class User extends DatabaseBean {

	private static final long serialVersionUID = 1L;
	
	@DbField
	private String loginName;
	@DbField
	private String name;
	@DbField
	private String password;
	@DbField
	private String salt;
	@DbField
	private Date registerDate;
	@DbField
	private String email;
	@DbField
	private String status;
	@DbField
	private String activeCode;
	@DbField
	private String realname;
	@DbField
	private String mobile;
	@DbField
	private String phone;
	@DbField
	private String duty;
	@DbField
	private String url;
	@DbField(column="emploreeCount")
	private Integer emploree_count;
	@DbField
	private String fax;
	@DbField
	private String address;
	@DbField
	private String zip;
	@DbField
	private String orgName;
	@DbField
	private String industry;
	@DbField
	private String province;
	@DbField
	private String city;
	@DbField
	private String region;
	@DbField
	private Integer usertype;
	@DbField
	private Integer sex;
	
	public static final int USER_SEX_MAN = 1;
	public static final int USER_SEX_FEMALE = 0;
	public static final int USER_TYPE_COM = 1;
	public static final int USER_TYPE_GOV = 0;
	public static final int USER_TYPE_PER = 2;
	

	private List<Role> roleList = Lists.newArrayList(); // 有序的关联对象集合

	public User() {
	}
	
	public User(Long id) {
		this.id = id;
	}

	public String getLoginName() {
		return loginName;
	}
	
	public Integer getUsertype() {
		return usertype;
	}

	public void setUsertype(Integer usertype) {
		this.usertype = usertype;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getDuty() {
		return duty;
	}

	public void setDuty(String duty) {
		this.duty = duty;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getEmploree_count() {
		return emploree_count;
	}

	public void setEmploree_count(Integer emploree_count) {
		this.emploree_count = emploree_count;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getIndustry() {
		return industry;
	}

	public void setIndustry(String industry) {
		this.industry = industry;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}
	
	public List<Role> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}

	public String getRoleNames() {
		return Collections3.extractToString(roleList, "name", ", ");
	}

	public Date getRegisterDate() {
		return registerDate;
	}

	public void setRegisterDate(Date registerDate) {
		this.registerDate = registerDate;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	public String getActiveCode() {
		return activeCode;
	}

	public void setActiveCode(String activeCode) {
		this.activeCode = activeCode;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
